﻿@model EFEntity.Esf
@{
    ViewData["Title"] = "right_list_information";
}
<html>
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>编辑角色</title>
    <link rel="stylesheet"
          href="../../css/table.css" type="text/css" />
    <link href="~/animate.css" rel="stylesheet" />
    <script src="~/js/jquery-1.10.2.js"></script>
    <script src="~/js/vue.js"></script>
    <script src="~/jquery-easyui-1.3.5/jquery.easyui.min.js"></script>
    <link href="~/jquery-easyui-1.3.5/themes/bootstrap/easyui.css" rel="stylesheet" />
    <link href="~/jquery-easyui-1.3.5/themes/icon.css" rel="stylesheet" />

    <style type="text/css">
        .parent {
            margin-left: 50px;
        }

        .children {
            margin-left: 20%;
        }
    </style>
</head>
<body>
    <div id="tata">
        <form action="update" method="post">
            <table width="100%">
                <tr>
                    <td>
                        <font color="black">您正在做的业务是：人力资源--权限管理--编辑角色</font>
                    </td>
                </tr>
                <tr>
                    <td align="right">
                        <input type="button" value="修改角色"  v-on:click="update()" />
                        <input type="button" value="返回" class="BUTTON_STYLE1"
                               onclick="history.back()">
                    </td>
                </tr>
            </table>
            <table width="100%" border="1" cellpadding=3 cellspacing=1
                   bordercolorlight=#848284 bordercolordark=#eeeeee
                   class="TABLE_STYLE1">
                <tr>
                    <td class="TD_STYLE1">角色编号</td>
                    <td class="TD_STYLE2">
                        <input type="text" class="INPUT_STYLE2"
                               asp-for="id" readonly="readonly" id="rid" />
                    </td>
                    <td class="TD_STYLE1">角色名称</td>
                    <td class="TD_STYLE2">
                        <input type="text" class="INPUT_STYLE2"
                               asp-for="user_sf"  id="user_sf"/>
                    </td>
                </tr>
                <tr>
                    <td class="TD_STYLE1">角色说明</td>
                    <td class="TD_STYLE2">
                        <input type="text" class="INPUT_STYLE2"
                               asp-for="user_ms"  id="user_ms"/>
                    </td>
                    <td class="TD_STYLE1">角色是否可用</td>
                    <td class="TD_STYLE2">
                        <select asp-for="user_sfny" id="user_sfny">
                            <option value="是">是</option>
                            <option value="否">否</option>
                        </select >

                    </td>
                </tr>
            </table>
            <ul id="tt"></ul>@*树状图*@
        </form>
    </div>
    
</body>

</html>
<script type="text/javascript">
    var vm = new Vue({
        el: "#tata",
        data: {
            
        },
        methods: {
            SUpdate: function () {
                var ida = $("#rid").val();
                $("#tt").tree({
                    url: "/power/ququq?idl=" + ida,
                    checkbox: true,
                    onLoadSuccess: function (node, data) {
                        $(data).each(function (index, obj) {
                            if (obj.state == "closed") {
                                $("#tt").tree("expandAll");
                            }
                        });
                    }
                });

            },
            update: function () {
                var t = this;
                var id = $("#rid").val();
                var user_sf = $("#user_sf").val();
                var user_ms = $("#user_ms").val();
                var user_sfny = $("#user_sfny").val();
                $.ajax({
                    url: "/power/up?id=" + id + "&user_sf=" + user_sf + "&user_ms=" + user_ms + "&user_sfny=" + user_sfny,
                    type: "get",
                    success: function (zhi) {
                        if (zhi > 0) {
                            t.update1();
                        } else {
                            alert("修改失败");
                        }
                    }
                })
            },
            update1: function () {
                var t = this;
                var s_id = $("#rid").val();
                //需求：获取全勾和半勾的id值
                var ids = "";
                var nodes = $("#tt").tree("getChecked");	// get checked node
                nodes.forEach(function (item) {
                    ids += item.id + ",";
                });

                var nodes2 = $("#tt").tree("getChecked", "indeterminate");	// 获取不确定的节点
                nodes2.forEach(function (item) {
                    ids += item.id + ",";
                });
                ids = ids.substr(0, ids.length - 1);

                $.ajax({
                    url: "/power/update",
                    type: "post",
                    data: {
                        "sid": s_id, "ids": ids
                    },
                    success: function (msg) {
                        if (msg > 0 || msg == "" || msg == null) {
                            alert("操作成功");
                            t.SUpdate();
                            location.href = '/power/right_list';
                        }
                    }
                })
                console.info(ids);
            }
        },
        mounted: function () {
            this.SUpdate();
        }
    });
</script>


